Bug 611709 - Add gtk_statusbar_remove_all
authorGarrett Regier <alias301@gmail.com>
Sat, 15 May 2010 20:58:30 +0000 (13:58 -0700)
committerChristian Dywan <christian@twotoasts.de>
Wed, 2 Jun 2010 15:50:28 +0000 (17:50 +0200)
gtk/gtk.symbols
gtk/gtkstatusbar.c
gtk/gtkstatusbar.h

index 86f309f7c58a379ea951f248cd26aa107f987478..367ca90e797a84049e4b0c26067d387be1218fd8 100644 (file)
@@ -3253,6 +3253,7 @@ gtk_statusbar_new
 gtk_statusbar_pop
 gtk_statusbar_push
 gtk_statusbar_remove
+gtk_statusbar_remove_all
 gtk_statusbar_set_has_resize_grip
 #endif
 #endif
index ff7bc0fa0da85f6414e45d97e679a3fb28bc6e3f..81d28d02c82d7e5d939ea775074996b70a1d2e4a 100644 (file)
@@ -462,6 +462,72 @@ gtk_statusbar_remove (GtkStatusbar *statusbar,
     }
 }
 
+/**
+ * gtk_statusbar_remove_all:
+ * @statusbar: a #GtkStatusBar
+ * @context_id: a context identifier
+ *
+ * Forces the removal of all messages from a statusbar's
+ * stack with the exact @context_id.
+ *
+ * Since: 2.22
+ */
+void
+gtk_statusbar_remove_all (GtkStatusbar *statusbar,
+                          guint         context_id)
+{
+  GtkStatusbarMsg *msg;
+  GSList *prev, *list;
+
+  g_return_if_fail (GTK_IS_STATUSBAR (statusbar));
+
+  if (statusbar->messages == NULL)
+    return;
+
+  msg = statusbar->messages->data;
+
+  /* care about signal emission if the topmost item is removed */
+  if (msg->context_id == context_id)
+    {
+      gtk_statusbar_pop (statusbar, context_id);
+
+      prev = NULL;
+      list = statusbar->messages;
+    }
+  else
+    {
+      prev = statusbar->messages;
+      list = prev->next;
+    }
+
+  while (list != NULL)
+    {
+      msg = list->data;
+
+      if (msg->context_id == context_id)
+        {
+          if (prev == NULL)
+            statusbar->messages = list->next;
+          else
+            prev->next = list->next;
+
+          g_free (msg->text);
+          g_slice_free (GtkStatusbarMsg, msg);
+          g_slist_free_1 (list);
+
+          if (prev == NULL)
+            prev = statusbar->messages;
+
+          list = prev->next;
+        }
+      else
+        {
+          prev = list;
+          list = prev->next;
+        }
+    }
+}
+
 /**
  * gtk_statusbar_set_has_resize_grip:
  * @statusbar: a #GtkStatusBar
index 77558df23a9673441f5218e0bef416931f1af06d..875d80d65bf89acea58276e4a5d85b8696cacbb4 100644 (file)
@@ -102,6 +102,9 @@ void       gtk_statusbar_pop                (GtkStatusbar *statusbar,
 void       gtk_statusbar_remove                (GtkStatusbar *statusbar,
                                         guint         context_id,
                                         guint         message_id);
+void       gtk_statusbar_remove_all            (GtkStatusbar *statusbar,
+                                        guint         context_id);
+                                        
 
 void     gtk_statusbar_set_has_resize_grip (GtkStatusbar *statusbar,
                                            gboolean      setting);